<?php

namespace App\Http\Controllers\Mobile\Company;
use App\Facades\Style;
use App\Models\Company\CompanySearch;
use Illuminate\Http\Request;

class CompanySearchController extends CommonController{

    /**
     * 搜索器列表
     * @return mixed
     */
    public function index(){
        $user = auth()->guard('company')->user();
        $companySearch = CompanySearch::where('uid',$user->uid)->orderBy('updated_at','desc')->paginate(10);
        foreach($companySearch as $k=> $v ){
            $alinks = arrayFilter(array(
                "jobsort1" => !empty($v->jobsort1) ? $v->jobsort1 : '',
                "jobsort2" => !empty($v->jobsort2) ? $v->jobsort2 : '',
                "jobsort3" => !empty($v->jobsort3) ? $v->jobsort3 : '',
                "jobsort4" => !empty($v->jobsort4) ? $v->jobsort4 : '',
                "jobsort5" => !empty($v->jobsort5) ? $v->jobsort5 : '',
                "jobarea1" => !empty($v->jobarea1) ? $v->jobarea1 : '',
                "jobarea2" => !empty($v->jobarea2) ? $v->jobarea2 : '',
                "jobarea3" => !empty($v->jobarea3) ? $v->jobarea3 : '',
                "jobarea4" => !empty($v->jobarea4) ? $v->jobarea4 : '',
                "jobarea5" => !empty($v->jobarea5) ? $v->jobarea5 : '',
                "education" => !empty($v->education) ? $v->education : '',
                "work_year" => !empty($v->work_year) ? $v->work_year : '',
                "age" => !empty($v->age) ? $v->age : '',
                "sex" => !empty($v->sex) ? $v->sex : '',
                "chkphoto_open" => !empty($v->chkphoto_open) ? $v->chkphoto_open : '',
                "homeaddress" => !empty($v->homeaddress) ? $v->homeaddress : '',
                "census" => !empty($v->census) ? $v->census : '',
                "keyword" => !empty($v->keyword) ? $v->keyword : '',
                "updatetime" => !empty($v->updatetime) ? $v->updatetime : '',
            ));
            //设置a连接属性
            $search = '';
            foreach($alinks as $kk => $vv){
                $search .= $kk . '=' . $vv .'&';
            }
            $search = '?'.trim($search,'&');
            $v->search_link = asset('mobile/personnel'.$search);
        }
        return Style::view('mobile.company.searchIndex',compact('companySearch'));
    }

}